{% extends 'preheat/base.html' %}

{% block title %}添加请求地址 - CDN预热平台{% endblock %}

{% block page_title %}添加请求地址{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header">
        <h3>请求地址信息</h3>
    </div>
    <div class="card-body">
        <form method="post">
            {% csrf_token %}
            
            <!-- 批量请求地址 -->
            <div id="batch_url_section">
                <div class="form-group">
                    <label for="id_batch_urls">批量请求地址</label>
                    {{ form.batch_urls }}
                    {% if form.batch_urls.errors %}
                    <div class="text-danger">
                        {{ form.batch_urls.errors }}
                    </div>
                    {% endif %}
                    <small class="form-text text-muted">每行输入一个URL，如：/image/logo1.png</small>
                </div>
            </div>
            
            <div class="form-group">
                <label for="id_cdn_domain">关联CDN域名</label>
                {{ form.cdn_domain }}
                {% if form.cdn_domain.errors %}
                <div class="text-danger">
                    {{ form.cdn_domain.errors }}
                </div>
                {% endif %}
            </div>
            
            <button type="submit" class="btn btn-primary">提交</button>
            <a href="{% url 'preheat:request_url_list' %}" class="btn btn-secondary">取消</a>
        </form>
    </div>
</div>
{% endblock %}

{% block extra_css %}
<style>
    .form-control {
        margin-bottom: 10px;
    }
    
    .form-check-label {
        margin-right: 15px;
    }
</style>
{% endblock %}

{% block extra_js %}
<script>
    // 当页面加载完成后设置表单
    document.addEventListener('DOMContentLoaded', function() {
        // 隐藏原始的URL字段
        const urlFieldset = document.querySelector('label[for="id_url"]').parentElement.parentElement;
        urlFieldset.style.display = 'none';
    });
</script>
{% endblock %}